package com.yl.danmo.controller;


import com.yl.common.core.utils.poi.ExcelUtil;
import com.yl.common.core.web.controller.BaseController;
import com.yl.common.core.web.domain.AjaxResult;
import com.yl.common.log.annotation.Log;
import com.yl.common.log.enums.BusinessType;
import com.yl.common.security.annotation.RequiresPermissions;
import com.yl.danmo.domain.DanmoInformationGuo;
import com.yl.danmo.service.IDanmoInformationGuoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 会员信息 国家级Controller
 * 
 * @author yl
 * @date 2025-04-12
 */
@RestController
@RequestMapping("/guo")
public class DanmoInformationGuoController extends BaseController
{
    @Autowired
    private IDanmoInformationGuoService danmoInformationGuoService;

    /**
     * 查询会员信息 国家级列表
     */
//    @RequiresPermissions("system:guo:list")
    @PostMapping("/list")
    public List<DanmoInformationGuo> list(@RequestBody DanmoInformationGuo danmoInformationGuo)
    {

        List<DanmoInformationGuo> list = danmoInformationGuoService.selectDanmoInformationGuoList(danmoInformationGuo);
        return list;
    }

    /**
     * 导出会员信息 国家级列表
     */
    @RequiresPermissions("system:guo:export")
    @Log(title = "会员信息 国家级", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoInformationGuo danmoInformationGuo)
    {
        List<DanmoInformationGuo> list = danmoInformationGuoService.selectDanmoInformationGuoList(danmoInformationGuo);
        ExcelUtil<DanmoInformationGuo> util = new ExcelUtil<DanmoInformationGuo>(DanmoInformationGuo.class);
        util.exportExcel(response, list, "会员信息 国家级数据");
    }

    /**
     * 获取会员信息 国家级详细信息
     */
    @RequiresPermissions("system:guo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {

        return success(danmoInformationGuoService.selectDanmoInformationGuoById(id));
    }

    /**
     * 新增会员信息 国家级
     */
    @RequiresPermissions("system:guo:add")
    @Log(title = "会员信息 国家级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DanmoInformationGuo danmoInformationGuo)
    {
        return toAjax(danmoInformationGuoService.insertDanmoInformationGuo(danmoInformationGuo));
    }

    /**
     * 修改会员信息 国家级
     */
    @RequiresPermissions("system:guo:edit")
    @Log(title = "会员信息 国家级", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DanmoInformationGuo danmoInformationGuo)
    {
        return toAjax(danmoInformationGuoService.updateDanmoInformationGuo(danmoInformationGuo));
    }

    /**
     * 删除会员信息 国家级
     */
    @RequiresPermissions("system:guo:remove")
    @Log(title = "会员信息 国家级", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoInformationGuoService.deleteDanmoInformationGuoByIds(ids));
    }


    /**
     * 清洗数据
     */
    @PostMapping("/clean")
    public String clean(@RequestBody DanmoInformationGuo danmoInformationGuo)
    {

        //开始时间
        long startTime = System.currentTimeMillis(); // 获取开始时间
        System.out.println("开始时间：" + startTime);



        danmoInformationGuoService.clean(danmoInformationGuo);

        long endTime = System.currentTimeMillis(); // 获取结束时间
        System.out.println("结束时间：" + endTime);

        long duration = endTime - startTime; // 计算耗时

        System.out.println("耗时：" + duration + " 毫秒");
        System.out.println("耗时：" + duration / 1000 + " 秒");
        System.out.println("耗时：" + duration / 60000 + " 分钟");
        System.out.println("耗时：" + duration / 60000 + " 分钟");


        return  new String("添加成功");
    }
}
